{% extends 'layout/gallery.htm' %}
{% block g_body %}

{% macro item_box(item) %}  
  
  {% if item.getClass == 'Album' %}
    {% set beginlink = '?album=' %}    
    {% set imagesrc = 'images/album.png' %}    
    {% set caption = item.getCaption %}     
    {% set link = '<a href = "'~beginlink~item.getPath~'">' %}     
  {% else %}
    {% set beginlink = 'loadDetail(\'?detail=' %}
    {% set endlink = '\');' %}
    {% set imagesrc = 'getimage.php?w=200&h=140&image='~item.getPath %}
    {% set caption = item.getCaption %}    
    {% set link = '<a href = "#" onclick="'~beginlink~item.getPath~endlink~'">' %}     
  {% endif %}
 
{{link | raw}}
<div class='box_item '>        
    <div class='box_image'>
       <img src='{{imagesrc}}'  />
    </div>
    <div class='box_caption'>
       {{caption}} 
    </div>
</div>
</a>    
{% endmacro %}


<div id="detail_content"></div>
<script type="text/javascript" src="js/load_detail.js"></script>

<div id="header_panel">
<div id='album_title'>
<h1>{{gallery.getAlbum.caption}} :</h1>
</div>

<div id="userbar">
{%- if login -%}
<div class="userbar_item" id="username"><div>{{user.getDisplayName}} (<a href="logout.php">logout</a>)</div></div>
{% else %}
<div class="userbar_item">
<form action="" method="post">
  <input type="text" name="openid_identifier" id="openid_identifier"/>
  <script id="__openidselector" src="https://www.idselector.com/widget/button/1"></script>
  <input type="submit" value="Sign in" style="vertical-align:middle;"/>
</form>
</div>
{% endif %}
</div>


{%- if login -%}
<div id="toolbar">
{% if gallery.getAlbum.parent %}
<a href = "?album={{gallery.getAlbum.getParent.getPath}}" class="toolbutton" id="goToParentButton">
<div class="toolbutton">
       ../
</div>
</a>
{% endif %}
{% if user.isAdmin %}
<a href="admin.php" class="toolbutton">
  <div class="toolbutton">
    <img src="images/toolbar/key.png" alt="Admin panel"/>
  </div>
</a>
{%endif %}
<a href="index.php?settings" class="toolbutton">
  <div class="toolbutton">
    <img src="images/toolbar/cog.png" alt="Nastavenia"/>
  </div>
</a>
</div>
{% endif %}

</div>

<div id="album_plane">
{#
{% for item in gallery.getItems %}      
  {{_self.item_box(item)}}
{% endfor %}
#}
<div class="cleaner">&nbsp;</div>
</div>

{% endblock %}